Skip to content

MWPW-183572: MAS Studio — AI assistant, product catalog, release flow, OST monorepo integration#776

Draft
Axelcureno wants to merge 3 commits intomainfrom
MWPW-183572
Draft

MWPW-183572: MAS Studio — AI assistant, product catalog, release flow, OST monorepo integration#776
Axelcureno wants to merge 3 commits intomainfrom
MWPW-183572

Conversation

@Axelcureno
Copy link
Copy Markdown
Member

@Axelcureno Axelcureno commented Apr 21, 2026

MAS Studio AI assistant, product catalog, release-flow enhancements, and the mas-ost monorepo workspace integration.

Resolves https://jira.corp.adobe.com/browse/MWPW-183572
QA Checklist: https://wiki.corp.adobe.com/display/adobedotcom/M@S+Engineering+QA+Use+Cases

What is in this PR

Two commits, both tagged with the Jira ticket:

  1. MWPW-183572: AI chat assistant, product catalog, release flow + IO Runtime — the full feature delivery plus the pre-review audit fixes baked in.
  2. MWPW-183572: integrate mas-ost as a monorepo workspace — OST source relocated from tacocat.js/mas-ost into this repo as the 4th npm workspace. Distinct architectural change, separate commit so reviewers can isolate the build/workspace question.

Feature commit contents

Studio frontend

  • Conversational AI chat (mas-chat.js + friends): Bedrock-backed, persistent sessions via chat-session-manager, operation preview + confirmation gating, destructive-tool allowlist enforced on the client.
  • Product catalog (mas-product-catalog.js / mas-product-detail.js): multi-select filters, surface-scoped editor/settings access (groups.js introduces isMasAdmin, canAccessSettings, getUserSurfaces), DRAFT landscape toggle, applied-filter chips.
  • MCS-integrated release flow: deterministic fragment content sourced from MCS merchandising data, dual-OSI plumbing for plans variants, multi-select OST hookup in rte/ost.js.
  • services/mcp-client.js: defensive guards on MCP response shapes (publish/get/copy/update contract drifts), AbortController on the AI chat fetch, URL-scrubbed logError helper applied across 14 call sites.
  • utils/ai-card-mapper.js: XSS-safe badge HTML via escape helpers; preserves explicit falsy field values (0, '', false); trim-aware title fallback chain.
  • utils/mas-chat-helpers.js: pure helpers extracted for direct unit testing.
  • markdown-parser.js: LRU-bounded cache to short-circuit repeat renders.

IO Runtime — AI chat backend (io/studio/src/ai-chat/)

  • AWS Bedrock integration with prompt-injection defense via wrapUntrusted sentinel envelopes. Attached-card fragment IDs wrapped element-wise instead of raw JSON.stringify to close a breakout vector.
  • Modules: bedrock-client, operations-handler, operations-prompt, prompt-templates, response-parser, variant-configs, variant-knowledge-builder, knowledge-client, validation, index.js.

IO Runtime — MCP server (io/mcp-server/)

  • 31 runtime actions covering card + collection + offer + product CRUD/search.
  • Surface-scoped authz on fragment-creating actions (create-release-cards, create-card, create-collection, copy-card) via new helpers in lib/ims-validator.jsderiveSurfaceFromPath, fetchUserGroups, canEditSurface, requireSurfaceAccess. Prevents cross-surface mutation via direct API calls.

mas-mcp-server (stdio entry for Claude Code / Cursor)

  • Retired the Express HTTP bridge (http-server.js). Dropped cors / express deps + the http npm script.

Web components

  • Small audit touches on aem-fragment, merch-card-collection, Express pricing variants.

mas-ost workspace commit

  • 63-file source tree extracted from tacocat.js/mas-ost@f5a71b9: Lit 3 + Spectrum Web Components, Vite build, WTR tests.
  • Registered in root package.json workspaces. Build script outputs the IIFE bundle and copies to ../studio/ost/index.js in one step.
  • Byte-for-byte identical bundle output validated via in-browser smoke test (window.ost.openOfferSelectorTool exposed, all 5 custom elements registered, no JS errors at load).

Testing

  • Full studio suite: 1240 pass / 0 fail / 2 skipped (same as baseline on main).
  • 10 new characterization tests in studio/test/** covering every new service/util + 2 XSS + 1 prompt-injection repro.
  • 2 new tests in io/studio/test/ai-chat/ (bedrock-client, operations-handler).
  • 1 new file in io/mcp-server/test/lib/ with 23 tests: canEditSurface matrix, fetchUserGroups edge cases, full requireSurfaceAccess middleware integration.
  • mas-ost suite: 209 pass / 4 pre-existing upstream failures (3 country-picker SWC lifecycle + 1 OstStore.addOffer.tryBuy). Not regressions from the integration. Tracked as follow-up.

Please do the steps below before submitting your PR for a code review or QA

  • C1. Cover code with Unit Tests — 20+ new characterization tests; 1240 studio tests green.
  • C2. Add a Nala test (double check with #fishbags if nala test is needed).
  • C3. Verify all Checks are green (unit tests, nala tests) — studio suite green locally; CI will confirm.
  • C4. PR description contains working Test Page link where the feature can be tested.
  • C5: you are ready to do a demo from Test Page in PR.
  • C.6 read your Jira one more time to validate that you have addressed all AC and nothing is missing.

Follow-up (filed as deferred, not PR-blocking)

  • Per-fragment surface authz on id-based MCP mutations (update-card, delete-card, publish-card, bulk-*). This PR gates path-based creation; id-based mutations currently rely on AEM's own ACLs to scope access.
  • Dev-namespace 14257-merchatscale-axel remains hardcoded in studio/src/constants.js, studio/src/services/product-api.js, and io/studio/src/ai-chat/knowledge-client.js with a TODO pointing at the post-merge swap to masstudio once that deploy completes.
  • 4 pre-existing mas-ost tests inherited from upstream (country-picker SWC + OstStore tryBuy) need fixing.
  • io/knowledge (the AI knowledge service / RAG backend) was intentionally scoped out of this PR. It's a separate Runtime app with its own lifecycle; RAG_ENABLED=false keeps the chat fully functional without it.

Test URLs:

Screenshots

To be added: OST dialog opened from AI chat, product catalog with multi-select filters, AI chat confirmation summary, release card preview.

@aem-code-sync
Copy link
Copy Markdown

aem-code-sync Bot commented Apr 21, 2026

Hello, I'm the AEM Code Sync Bot and I will run some actions to deploy your branch.
In case there are problems, just click the checkbox below to rerun the respective action.

  • Re-sync branch
Commits

Axelcureno and others added 3 commits April 21, 2026 11:54
…ntime

Delivers the MAS Studio AI assistant experience and its supporting
infrastructure. Everything ships in one commit so reviewers see a
coherent feature set.

Studio frontend (studio/src/):
- AI chat UI: mas-chat.js + mas-chat-message.js + mas-chat-input.js +
  mas-chat-product-cards.js + mas-chat-session-selector.js +
  mas-chat-confirmation-summary.js + mas-chat-button-group.js +
  mas-chat-drawer.js + mas-chat-fab.js. Persistent sessions via
  chat-session-manager, markdown rendering with an LRU-bounded cache,
  operation-preview and destructive-tool confirmation gating.
- Product catalog (mas-product-catalog.js + mas-product-detail.js) with
  multi-select filters, surface-scoped editor/settings access via
  groups.js (isMasAdmin + canAccessSettings + getUserSurfaces), DRAFT
  landscape toggle, applied-filter chips.
- MCS-integrated release flow: deterministic fragment content from
  MCS merchandising data, dual-OSI plumbing for plans variants,
  multi-select OST hooked through rte/ost.js.
- Shared services: mcp-client.js (defensive guards on response shape,
  AbortController on chat fetch, error-log scrubbing via logError).
- utils/ai-card-mapper.js: XSS-escaped badge rendering, falsy-value
  preservation on fragment fields, trim-aware title fallbacks.
- utils/mas-chat-helpers.js: pure helpers extracted for unit testing.

IO Runtime - AI chat backend (io/studio/src/ai-chat/):
- bedrock-client.js with prompt-injection defense via wrapUntrusted
  sentinel envelopes; attached-card fragment IDs wrapped element-wise
  instead of raw JSON.stringify.
- operations-handler, operations-prompt, prompt-templates,
  response-parser, variant-configs, variant-knowledge-builder,
  knowledge-client, validation, index.js.

IO Runtime - MCP server actions (io/mcp-server/):
- 31 runtime actions (card + collection + offer + product CRUD/search).
- Surface-scoped authz on fragment-creating actions
  (create-release-cards, create-card, create-collection, copy-card):
  deriveSurfaceFromPath + fetchUserGroups + canEditSurface +
  requireSurfaceAccess helpers in lib/ims-validator.js. Prevents
  cross-surface mutation via direct API calls.

mas-mcp-server (stdio entry for Claude Code / Cursor):
- Retired the Express HTTP bridge (http-server.js). Dropped
  cors/express deps + the 'http' npm script.

Web-components:
- Small audit touches on aem-fragment, merch-card-collection,
  variants/full-pricing-express, variants/simplified-pricing-express.

Testing:
- 10 new characterization-test files in studio/test/** covering every
  new service/util plus 2 XSS + 1 prompt-injection repro.
- 2 new test files in io/studio/test/ai-chat/.
- 1 new test file in io/mcp-server/test/lib/ covering surface authz
  (23 tests: canEditSurface matrix, fetchUserGroups, full middleware
  integration).

Out of scope (deferred to follow-ups):
- Per-fragment surface authz on id-based MCP mutations
  (update/delete/publish/bulk-*) - currently rely on AEM's own ACLs.
- Translation work that entered this branch via a main merge is
  included as-is from main (no ticket changes to the translation
  subsystem).
Moves the OST (Offer Selector Tool) source from the separate
tacocat.js/mas-ost tree into this repo as the 4th npm workspace
alongside studio/, web-components/, and io/studio/.

Changes:
- mas-ost/ tree with Lit 3 + Spectrum Web Components source, Vite
  build config, WTR tests, and dev HTML pages. 63 source + test
  files extracted from tacocat.js commit f5a71b9.
- Root package.json registers mas-ost in the workspaces array.
- mas-ost/package.json build script outputs the IIFE bundle and
  copies it to ../studio/ost/index.js in one step (replaces the
  previous cross-repo deploy:local workflow).
- Root package-lock.json regenerated by npm install to wire the
  new workspace and dedupe Lit/SWC against the root.

Bundle output (studio/ost/index.js) is already in the previous
commit alongside the frontend consumer changes. This commit adds
the source side so the OST is maintained in-repo going forward.

Known: 4 mas-ost unit tests fail upstream (3 country-picker SWC
lifecycle + 1 OstStore.addOffer.tryBuy). Inherited from the source,
not regressions from the relocation. Tracked as follow-up.
- Deterministic router for bare offer IDs, arrangement codes, and OSIs
  so PA codes and arrangement slugs (e.g. cptv_direct_individual) no
  longer misclassify as OSIs.
- Offer-id fallback in resolveOfferSelector for 32-hex IDs that OST
  surfaces in the OSI slot for draft offers.
- Trial-CTA yes/no step inserted on the OST Use shortcut path so users
  can still add a free-trial offer when seeding from a single offer.
- Rename "Annual, paid monthly" to "Annual, billed monthly" (ABM).
- Product card auto-selects its single match via productCardsSelectedValue
  so the preview card renders as confirmed, not clickable.
- OST: pin filled-slot colors to light-palette hex so labels stay
  readable against saturated-green backgrounds in dark themes.
- OST: hide the "BOTH" landscape badge (kept per-offer source badges).
- Replace sp-icon-offer with sp-icon-label for the Search offers chip.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant